package com.xingzuo.library_user.ui;

import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.example.zhouwei.library.CustomPopWindow;
import com.xingzuo.base.app.AppActivityKey;
import com.xingzuo.base.ui.mvp.base.ui.BaseMvpActivity;
import com.xingzuo.library_user.R;
import com.xingzuo.library_user.R2;
import com.xingzuo.library_user.contract.MessageContract;
import com.xingzuo.library_user.presenter.UserDetailPresenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

@Route(path = AppActivityKey.USERDETAILACTIVITY)
public class UserDetailActivity extends BaseMvpActivity<UserDetailPresenter> implements MessageContract.View {
    @BindView(R2.id.rv_back)
    ImageView rvBack;
    @BindView(R2.id.rv_more)
    ImageView rvMore;
    @BindView(R2.id.fl_title)
    FrameLayout flTitle;
    @BindView(R2.id.iv_pic)
    ImageView ivPic;
    @BindView(R2.id.tv_name)
    TextView tvName;
    @BindView(R2.id.tv_address)
    TextView tvAddress;
    @BindView(R2.id.tv_biaoqian)
    TextView tvBiaoqian;
    @BindView(R2.id.tv_chakan)
    TextView tvChakan;

    @Override
    public UserDetailPresenter getPresenter() {
        return new UserDetailPresenter();
    }

    @Override
    public int getView() {
        return R.layout.activity_userdetail;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initLinsenterner() {

    }

    @Override
    public void getData() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R2.id.rv_back, R2.id.rv_more, R2.id.tv_chakan})
    public void onViewClicked(View view) {
        int id = view.getId();
        if (id == R.id.rv_back) {
            finishActivity();
        } else if (id == R.id.rv_more) {
            View contentView = LayoutInflater.from(mContext).inflate(R.layout.dialog_user_more, null);
            CustomPopWindow popWindow = null;
            popWindow = new CustomPopWindow.PopupWindowBuilder(mContext).size(WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.WRAP_CONTENT)
                    .setView(contentView)//显示的布局
                    .enableBackgroundDark(true)
                    .create()//创建PopupWindow
                    .showAtLocation(rvMore, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
            CustomPopWindow finalPopWindow = popWindow;
            View.OnClickListener listener = new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (finalPopWindow != null) {
                        finalPopWindow.dissmiss();
                    }
                    int id = v.getId();
                   /* if (id == R.id.iv_close) {

                    } else if (id == R.id.tv_nan) {

                    } else if (id == R.id.tv_nv) {

                    }*/
                }
            };
           /* contentView.findViewById(R.id.tv_quxiao).setOnClickListener(listener);
            contentView.findViewById(R.id.tv_nan).setOnClickListener(listener);
            contentView.findViewById(R.id.tv_nv).setOnClickListener(listener);*/
        } else if (id == R.id.tv_chakan) {
            startIntent(AppActivityKey.LOOKASTROLABEACTIVITY);
        }
    }
}